<?php

/**
 * module1 actions.
 *
 * @package    GCM_Project
 * @subpackage module1
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class module1Actions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
  	//spl_autoload_register();
  	//this->imglist = $myFunc->list_img_files("");
    //$this->forward('default', 'module');
  }
  
  public function executeUpload(sfWebRequest $request){
  	$foto_upload = new Foto_upload;	

	$json['size'] = $_POST['MAX_FILE_SIZE'];
	$json['img'] = '';
	
	$foto_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/uploads/images/";
	$foto_upload->foto_folder = $_SERVER['DOCUMENT_ROOT']."/uploads/images/";
	$foto_upload->thumb_folder = $_SERVER['DOCUMENT_ROOT']."/uploads/images/thumb/";
	$foto_upload->extensions = array(".jpg", ".gif", ".png");
	$foto_upload->language = "en";
	$foto_upload->x_max_size = 480;
	$foto_upload->y_max_size = 360;
	$foto_upload->x_max_thumb_size = 100;
	//$foto_upload->y_max_thumb_size = 240;
	
	$foto_upload->the_temp_file = $_FILES['fileToUpload']['tmp_name'];
	$foto_upload->the_file = $_FILES['fileToUpload']['name'];
	$foto_upload->http_error = $_FILES['fileToUpload']['error'];
	$foto_upload->rename_file = false; 
	
	if ($foto_upload->upload()) {
		$foto_upload->process_image(false, true, false, 50);
		$json['img'] = $foto_upload->file_copy;
	} 
	
	$json['error'] = strip_tags($foto_upload->show_error_string());
	$this->data = json_encode($json);
	//echo json_encode($json);
  	//$this->$data['img'] = "Koala.jpg";
  	//$this->$data['error'] = "this is messages";
  	
  }
  
  public function executeCard(sfWebRequest $request){
  	
  }
  public function executeTree(sfWebRequest $request){
  	
  }
}
